home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12759 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  61 lines

  1. Newsgroups: comp.lang.c++
  2. Path: in2.uu.net!world!mv!usenet
  3. From: ENGR@GSSI.MV.COM (Michael Furman)
  4. Subject: Re: Advanced C++ question...
  5. Message-ID: <DoMH88.5wv@mv.mv.com>
  6. Mime-Version: 1.0
  7. Content-Type: Text/Plain; charset=US-ASCII
  8. Organization: GSSI
  9. Date: Thu, 21 Mar 1996 14:50:32 GMT
  10. References: <4iprfg$1ui@aadt>
  11. X-Newsreader: WinVN 0.99.7
  12. X-Nntp-Posting-Host: gssi.mv.com
  13.  
  14. In article <4iprfg$1ui@aadt>, david_hooker@sdt.com says...
  15. >
  16. >Hi all...
  17. >
  18. >I want to write an operator* for a class, but I want to do
  19. >one of 2 things:
  20. >   1. Call one of two different operator*'s depending on whether
  21. >      it is an lvalue or rvalue
  22. >   OR
  23. >   2. Somehow determine in the function if it is being used as an
  24. >      lvalue or an rvalue.
  25. >
  26. >For instance, I want to know, in the operator*, from which case I'm
  27. >being called:
  28. >
  29. >  *Object = SomeValue;     // used as an lvalue
  30. >
  31. >   SomeValue = *Object;    // used as an rvalue
  32. >
  33. >
  34. >The reason for this is that this class accesses data differently 
  35. depending
  36. >on if it is a read or write access.
  37.  
  38. It is impossible with "*" operator. But you can define conversion 
  39. functions
  40. for your class - it will allow exactly what you need.
  41.  
  42. >
  43. >Thanks...
  44. >
  45. >-dave-
  46. >
  47. >
  48. >
  49. >
  50.  
  51. -- 
  52. <<< If you received it by E-mail: it is a copy of post to the newsgroup 
  53. >>>
  54. ---------------------------------------------------------------
  55. Michael Furman,                       (603)893-1109
  56. Geophysical Survey Systems, Inc.  fax:(603)889-3984
  57. 13 Klein Drive - P.O. Box 97          engr@gssi.mv.com 
  58. North Salem, NH 03073-0097            71543.1334@compuserve.com
  59. ---------------------------------------------------------------
  60.  
  61.